//
//  ZCTopCommentView.m
//  百思不得姐
//
//  Created by Ning Xie on 16/9/2.
//  Copyright © 2016年 zhangchong. All rights reserved.
//

#import "ZCTopCommentView.h"
#import "ZCEssenceModel.h"

@interface ZCTopCommentView ()

@property (weak, nonatomic) UILabel *topCmtLab;
@end

@implementation ZCTopCommentView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return  self;
}

-(void)setupUI{
    
    UILabel *topCmtLab = [[UILabel alloc]init];
    topCmtLab.font = [UIFont systemFontOfSize:13];
    topCmtLab.numberOfLines = 0;
    [topCmtLab sizeToFit];
    self.topCmtLab = topCmtLab;

    
    [self addSubview:topCmtLab];
    [topCmtLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(10);
        make.leading.equalTo(self).offset(0);
        make.trailing.equalTo(self);
    }];
    
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(topCmtLab).offset(10);
    }];
}

-(void)setModel:(ZCEssenceModel *)model{
    
    _model = model;
    
    NSString *userName = model.top_cmt.firstObject[@"user"][@"username"];
    NSString *text = model.top_cmt.firstObject[@"content"];
    self.topCmtLab.textColor = [UIColor grayColor];
    self.topCmtLab.text = [NSString stringWithFormat:@"%@:%@",userName,text];
}

@end
